# 导包
import x.lang.system
import x.lang.time

# 定义变量
var res1:int = 1
var res2:int = 1

# 结果
var sum:int = res2

# 计算斐波那契数
fun fibonacci := () -> {
    var res:int = res1
    set res += res2
    set sum = res
    set res1 = res2
    set res2 = sum
}

# 索引
var index:int = 2

# 循环函数
fun loop := (n) -> {
    if (index < n) -> {
        fibonacci()
        set index++
        loop(n)
    }
}

# 开始计算
const start_time:int = time()
loop(30)
const end_time:int = time()

# 耗时
var cost_time:int = end_time
set cost_time -= start_time

# 输出结果
println("Fibonacci of 30 is", sum)
println("Time:", cost_time, "ms")